package com.mzy.datepackage.M2022.Jan.nine;

import com.mzy.model.PageDTO;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author mzy
 * @Date 2022/1/7 7:19
 * @Version 1.0
 */
public class Demo {
    public static void main(String[] args) {


        ArrayList<mobile> objects = new ArrayList<mobile>();
        objects.add(new mobile("aaa", "bbb", "ccc"));
        objects.add(new mobile("我家", "bbb", "ccc"));
        objects.add(new mobile("美国么", "bbb", "ccc"));
        objects.add(new mobile("中国么", "bbb", "ccc"));
        objects.add(new mobile("非洲", "bbb", "ccc"));

        PageDTO pageDTO = new PageDTO();

        pageDTO.setPageNum(2);
        pageDTO.setPageSize(2);

        List<mobile> collect = objects.stream().skip((pageDTO.getPageNum() - 1) * pageDTO.getPageSize()).limit(pageDTO.getPageSize()).collect(Collectors.toList());

        model model1 = new model();
        model1.setInfoLists(collect);
        model1.setTotal(objects.size());
        model1.setPageNum(pageDTO.getPageNum());
        model1.setPageSize(pageDTO.getPageSize());
        model1.setTotalPageNum(objects.size() % pageDTO.getPageSize() == 0 ? (objects.size() / pageDTO.getPageSize()) : (objects.size() / pageDTO.getPageSize() + 1));


        collect.forEach(model -> System.out.println(model));

        System.out.println(model1);


        ArrayList<String> ss = new ArrayList<>();

        ss.add("中国");
        ss.add("美国");
        ss.add("英国");

        List<String> kk = ss.stream().filter(e ->
                e.contains("国")).collect(Collectors.toList());

        System.out.println(kk);
    }

}
